//
//  DLFalseMineVC.m
//  delongzhitou
//
//  Created by Mr.Wang on 2019/1/2.
//  Copyright © 2019 delongzhitou. All rights reserved.
//

#import "DLFalseMineVC.h"
#import "DLFalseMineCellView.h"
#import "DLOpinionReportVC.h"

@interface DLFalseMineVC ()

@end

@implementation DLFalseMineVC

- (void) viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self setUpNav];
}
- (void) viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    kuserManager.currentTabIndex = 2;
}
- (void) setUpNav {
    
    //    self.navigationItem.leftBarButtonItem = [UIBarButtonItem new];
    self.navigationController.navigationBarHidden = YES;
    self.navigationController.navigationBar.translucent = YES;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self layoutSubControls];
    // Do any additional setup after loading the view.
}
- (void) layoutSubControls {
    
    self.view.backgroundColor = kDLViewNormalBgColor;
    
    UIView *falseNavView = [UIView new];
    falseNavView.frame = CGRectMake(0, 0, kScreenWidth, 125);
    falseNavView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"normal_navbg"]];
    [self.view addSubview:falseNavView];
    
    UIImageView *iconImgV = [UIImageView new];
    iconImgV.frame = CGRectMake(19, 20 + (125 - 55 - 20) / 2, 55, 55);
    iconImgV.layer.cornerRadius = iconImgV.width / 2;
    iconImgV.clipsToBounds = YES;
    iconImgV.image = [UIImage imageNamed:@"robot_bg"];
    [falseNavView addSubview:iconImgV];
    iconImgV.backgroundColor = [UIColor cyanColor];
    
    UILabel *titleLabel = [UILabel new];
    titleLabel.frame = CGRectMake(iconImgV.right + 19, iconImgV.top, 140, 55);
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.textAlignment = NSTextAlignmentLeft;
    titleLabel.font = kSystemFont(14);
    titleLabel.text = kuserManager.userInfoModel.mobile;
    [falseNavView addSubview:titleLabel];
    
    UIButton *machineBtn = [UIButton buttonWithType:0];
    machineBtn.frame = CGRectMake(falseNavView.width - 40, (falseNavView.height - 40 * 2 /3) / 2, 40 * 2 / 3, 40 * 2 /3);
    [machineBtn setImage:[UIImage imageNamed:@"info_robot"] forState:UIControlStateNormal];
    [machineBtn addTarget:self action:@selector(machineBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [falseNavView addSubview:machineBtn];
    
    DLFalseMineCellView *falseView1 = [[DLFalseMineCellView alloc] initWithFrame:CGRectMake(0, falseNavView.bottom + 10, kScreenWidth, 58)];
    [falseView1 configSubControlsWithTitle:@"修改登录密码" andSubTitle:@""];
    [self.view addSubview:falseView1];
    
    DLFalseMineCellView *falseView2 = [[DLFalseMineCellView alloc] initWithFrame:CGRectMake(falseView1.left, falseView1.bottom + 1, falseView1.width, falseView1.height)];
    [falseView2 configSubControlsWithTitle:@"关于我们" andSubTitle:@"版本号"];
    [self.view addSubview:falseView2];
    
    DLFalseMineCellView *falseView3 = [[DLFalseMineCellView alloc] initWithFrame:CGRectMake(falseView2.left, falseView2.bottom + 1, falseView2.width, falseView2.height)];
    [falseView3 configSubControlsWithTitle:@"意见反馈" andSubTitle:@""];
    [self.view addSubview:falseView3];
    
    
    UIButton *exitButton = [UIButton buttonWithType:0];
    exitButton.frame = CGRectMake(25, kScreenSafeAreaHeight - kHeightNavigation - 60, kScreenWidth - 50, 44);
    [exitButton setTitle:@"退出登录" forState:UIControlStateNormal];
    [exitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    exitButton.titleLabel.font = kSystemFont(15);
    exitButton.backgroundColor = kDLBtnNormalBgColor;
    exitButton.layer.cornerRadius = 3;
    exitButton.clipsToBounds = YES;
    [self.view addSubview:exitButton];
    [exitButton addTarget:self action:@selector(exitButtonClick) forControlEvents:UIControlEventTouchUpInside];
}
- (void) machineBtnClick {
    DLMachineDetailVC *machineDetailVC = [DLMachineDetailVC new];
    [kuserManager.lastVc.navigationController pushViewController:machineDetailVC animated:YES];
}
- (void) exitButtonClick {
    NSLog(@"退出登录");
    [kuserManager userLogout];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
